package com.secret.chain.secretchain.controller.wx;
import com.secret.chain.secretchain.domain.entity.Problem;
import com.secret.chain.secretchain.result.Result;
import com.secret.chain.secretchain.service.ProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wx/problem")
@CrossOrigin
public class ProblemController {
    @Autowired
    private ProblemService problemService;

    @DeleteMapping
    public Result<Void> delete(Integer id){
        return problemService.delete(id);
    }

    @GetMapping("{groupId}")
    public Result<Problem> queryByGroupId(@PathVariable Integer id){
        return problemService.queryByGroupId(id);
    }

    @GetMapping("{answerUserId}")
    public Result<Problem> queryByGroupAnswerUserId(@PathVariable Integer id){
        return problemService.queryByGroupAnswerUserId(id);
    }

    @GetMapping("{askUserId}")
    public Result<Problem> queryByGroupAskUserId(@PathVariable Integer id){
        return problemService.queryByGroupAskUserId(id);
    }

    @PostMapping
    public Result<Void> save(@RequestBody Problem problem){
        return problemService.save(problem);
    }

    @PutMapping
    public Result update(@RequestBody Problem problem){
        return problemService.update(problem);
    }







}
